<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Return current cache expire</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="ref.session.html">Session 函数</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.session-cache-limiter.html">session_cache_limiter</a></div>
 <div class="up"><a href="ref.session.html">Session 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.session-cache-expire" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">session_cache_expire</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5)</p><p class="refpurpose"><span class="refname">session_cache_expire</span> &mdash; <span class="dc-title">Return current cache expire</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.session-cache-expire-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">int</span> <span class="methodname"><strong>session_cache_expire</strong></span>
    ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$new_cache_expire</code></span>
  ] )</div>

  <p class="para rdfs-comment">
   <span class="function"><strong>session_cache_expire()</strong></span> returns the current setting of
   <em>session.cache_expire</em>. 
  </p>
  <p class="para">
   The cache expire is reset to the default value of 180 stored in
   <a href="session.configuration.html#ini.session.cache-expire" class="link">session.cache_expire</a>
   at request startup time. Thus,
   you need to call <span class="function"><strong>session_cache_expire()</strong></span> for every
   request (and before <span class="function"><a href="function.session-start.html" class="function">session_start()</a></span> is called).
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.session-cache-expire-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">new_cache_expire</code></em></dt>

     <dd>

      <p class="para">
       If <em><code class="parameter">new_cache_expire</code></em> is given, the current cache
       expire is replaced with <em><code class="parameter">new_cache_expire</code></em>.
      </p>
      <p class="para">
       <blockquote class="note"><p><strong class="note">Note</strong>: 
        <span class="simpara">
         Setting <em><code class="parameter">new_cache_expire</code></em> is of value only, if
         <em>session.cache_limiter</em> is set to a value
         <em class="emphasis">different</em> from <em>nocache</em>.
        </span>
       </p></blockquote>
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.session-cache-expire-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns the current setting of <em>session.cache_expire</em>.
   The value returned should be read in minutes, defaults to 180. 
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.session-cache-expire-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4667">
    <p><strong>Example #1 <span class="function"><strong>session_cache_expire()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">/*&nbsp;set&nbsp;the&nbsp;cache&nbsp;limiter&nbsp;to&nbsp;'private'&nbsp;*/<br /><br /></span><span style="color: #0000BB">session_cache_limiter</span><span style="color: #007700">(</span><span style="color: #DD0000">'private'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$cache_limiter&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">session_cache_limiter</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">/*&nbsp;set&nbsp;the&nbsp;cache&nbsp;expire&nbsp;to&nbsp;30&nbsp;minutes&nbsp;*/<br /></span><span style="color: #0000BB">session_cache_expire</span><span style="color: #007700">(</span><span style="color: #0000BB">30</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$cache_expire&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">session_cache_expire</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">/*&nbsp;start&nbsp;the&nbsp;session&nbsp;*/<br /><br /></span><span style="color: #0000BB">session_start</span><span style="color: #007700">();<br /><br />echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;cache&nbsp;limiter&nbsp;is&nbsp;now&nbsp;set&nbsp;to&nbsp;</span><span style="color: #0000BB">$cache_limiter</span><span style="color: #DD0000">&lt;br&nbsp;/&gt;"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;cached&nbsp;session&nbsp;pages&nbsp;expire&nbsp;after&nbsp;</span><span style="color: #0000BB">$cache_expire</span><span style="color: #DD0000">&nbsp;minutes"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.session-cache-expire-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><a href="session.configuration.html#ini.session.cache-expire" class="link">session.cache_expire</a></li>
    <li class="member"><a href="session.configuration.html#ini.session.cache-limiter" class="link">session.cache_limiter</a></li>
    <li class="member"><span class="function"><a href="function.session-cache-limiter.html" class="function" rel="rdfs-seeAlso">session_cache_limiter()</a> - Get and/or set the current cache limiter</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="ref.session.html">Session 函数</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.session-cache-limiter.html">session_cache_limiter</a></div>
 <div class="up"><a href="ref.session.html">Session 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
